﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Helpers;
using System.Web.Http;
using Gbu.BLTool.BaseTool;
using Gbu.BLTool.Entitys;
using Newtonsoft.Json;

namespace BlServiceDemo.Controllers
{
    public class UserController : ApiController
    {
        // GET api/user
        public string Get()
        {
            //return new string[] { "value1", "value2" };

            var retlist = new List<UserRet>();
            var age = 20;
            var name = "wangx";
            for (int i = 1; i < 5; i++)
            {
                var item = new UserRet()
                    {
                        Age = age+i,
                        Name = name+i.ToString(),
                        Sex = 1
                    };
                retlist.Add(item);
            }
            var ret=new CommResponseEntity<List<UserRet>>();
            ret.MessageCode = 0;
            ret.Status = 0;
            ret.Entity = retlist;
            return Json.Encode(ret);
        }

        // GET api/user/5
        [HttpGet]
        public object Get(string Id)
        {
            var ret = new UserRet();
            ret.Age = 20;
            ret.Name = "rocky";
            ret.Sex = 1;

            var nret = new CommResponseEntity<UserRet>()
                {
                    Entity = ret,
                    Status = 0,
                    Message = "",
                    MessageCode = 0
                };
            return nret;
        }

        //[HttpGet]
        //public object Get(string Id)
        //{
        //    var ret = new UserRet();
        //    ret.Age = 20;
        //    ret.Name = "rocky";
        //    ret.Sex = 1;
        //    return ret;
        //}


        // POST api/user
        public void Post([FromBody]string value)
        {
        }

        // PUT api/user/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/user/5
        public void Delete(int id)
        {
        }
    }
}
